import { Directive } from 'vue';
import { hasPermission } from './utils';

export { WithPermission } from './withPermission';
export { hasPermission };

export const permissionDirective: Directive = (el, binding) => {
  const { value } = binding;
  if (!hasPermission(value)) {
    el.parentNode && el.parentNode.removeChild(el);
  }
};
